ia.TextSubstitution Class
The TextSubstitution
class contains functions for
variable subtitution in strings.
All variables are indicated by the name of the variable. This class registers these names
with variable values, allowing the lookup of variable values
by the variable name. The set of available variables can be extended by using
the static setVariable
method to register a new variable name and
value.
Constructor
ia.TextSubstitution
()
Item Index
Methods
_formatValue
-
variableString
-
index
Extracts a variable / string / number from a conditional statement.
Parameters:
-
variableString
StringThe conditional statement.
-
index
NumberThe position of the variable in the statement.
Returns:
_leftTrim
-
s
Removes whitespace from the left side of a string.
Parameters:
-
s
StringThe string.
Returns:
_processVariable
-
variableString
Processes a conditional statement.
Parameters:
-
variableString
StringThe variable string.
_replace
-
s
-
pattern
-
replacement
Replaces a pattern in a string with a new pattern. eg. All occurrences of ";" may be replaced with ";".
Parameters:
-
s
StringThe string.
-
pattern
StringThe pattern.
-
replacement
StringThe pattern replacements.
Returns:
_rightTrim
-
s
Removes whitespace from the right side of a string.
Parameters:
-
s
StringThe string.
Returns:
_trim
-
s
Removes whitespace from a string.
Parameters:
-
s
StringThe string.
Returns:
clearVariables
()
Clears the variables.
formatMessage
-
msg
Replaces all instances of a variable name in a string with the 'real' values.
Parameters:
-
msg
StringThe input string which may contain variable names, for example: 'Current theme is: ${themeName1}'.
Returns:
setVariable
-
name
-
value
Sets the value for the given substitution variable.
Parameters:
-
name
StringThe name of the variable
-
value
StringThe value of the variable.